var aGeoLines = [];
var aGeoArrows = [];

function CreateArrow(oMap,oGeoLine) {
  var iZoom = oMap.getZoom();
  if (oGeoLine.Arrows[iZoom].length > 0) {
    var oArrow = new GPolygon([
      new GLatLng(oGeoLine.Arrows[iZoom][0].t, oGeoLine.Arrows[iZoom][0].g),
      new GLatLng(oGeoLine.Arrows[iZoom][1].t, oGeoLine.Arrows[iZoom][1].g),
      new GLatLng(oGeoLine.Arrows[iZoom][2].t, oGeoLine.Arrows[iZoom][2].g),
      new GLatLng(oGeoLine.Arrows[iZoom][0].t, oGeoLine.Arrows[iZoom][0].g)
    ],
     oGeoLine.Color,
     1,
     oGeoLine.Opacity,
     oGeoLine.Color,
     oGeoLine.Opacity
    );
    oMap.addOverlay(oArrow);
    aGeoArrows.push(oArrow);
  }
}

function CreateArrows(oMap) {
  for(i = 0; i < aGeoArrows.length; i++)
    oMap.removeOverlay(aGeoArrows[i]);
    
  aGeoArrows = [];
  
  for(i = 0; i < aGeoLines.length; i++) {
    CreateArrow(oMap, aGeoLines[i]);
  }
}

function AddGeoLine(oMap, oGeoLine) {
  var oStartLatLng = new GLatLng(oGeoLine.StartPoint.t, oGeoLine.StartPoint.g);
  var oEndLatLng = new GLatLng(oGeoLine.EndPoint.t, oGeoLine.EndPoint.g);
  var oPolyline = new GPolyline([oStartLatLng, oEndLatLng], oGeoLine.Color, oGeoLine.Width, oGeoLine.Opacity);
  
  if (aGeoLines.length == 0) {
    GEvent.addListener(oMap, "zoomend", function() { CreateArrows(oMap); });
  }
  
  aGeoLines.push(oGeoLine);
  oMap.addOverlay(oPolyline);
  CreateArrow(oMap,oGeoLine);
}



